package com.fpx.isp.admin.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

    @RequestMapping(value = "/testGet", method = RequestMethod.GET)
    @ResponseBody
    public String testGet(@RequestParam("name") String name, @RequestParam(required = false) String sex) {
        System.out.println(name);
        return "<response><name>" + name + "</name><sex>" + sex + "</sex><ack>success</ack></response>";
    }

    @RequestMapping(value = "/testPost", method = RequestMethod.POST)
    @ResponseBody
    public String testPost(@RequestParam("name") String name, @RequestBody String xml) {

        System.out.println(name);
        System.out.println(xml);
        return "<response><name>" + name + "</name><ack>success</ack></response>";
    }

    @RequestMapping(value = "/testPost2", method = RequestMethod.POST)
    @ResponseBody
    public String testPost2(@RequestParam(required = false) String name, @RequestBody String xml) {

        System.out.println(name);
        System.out.println(xml);
        return "<response><data><name>hello:" + name + "</name></data><ack>success</ack></response>";
    }

}
